home *** CD-ROM | disk | FTP | other *** search
- /*
- Searches the CD index files
- $VER: Search.rexx 1.1 (8.11.2000)
- (c) Neil Bothwick, Wirenet
-
- 1.1 - Uses "parse source" to get the name of the CD
- */
-
- /* ;;; Initialise */
- options results
- signal on error
- parse source . ' ' . ' ' . ' ' ScriptName ' ' .
- CDName = left(ScriptName, pos(':', ScriptName) - 1)
-
- call LoadLib('rexxsupport.library')
- call LoadLib('rexxdossupport.library')
- call LoadLib('rexxreqtools.library')
-
- parse arg args
- args = compress(args,'a0'x)
- do until args = ''
- parse var args a '"' b '"' args
- interpret a||'"'||b||'"'
- args = strip(args,'L')
- end
-
- if SearchStr = '' then call ExitMsg('You must give a string to search for')
- 'urlencode "'SearchStr'" var SearchEnc'
- OutputURL = 'x-aweb:searchresults/'SearchEnc
- OutputFile = 'T:CDsearch.results'
- AWebPort = address()
- if left(AWebPort,5) ~= 'AWEB.' then call ExitMsg('This script can only be run*Nfrom a link inside AWeb')
- ;;;
- /* ;;; Search */
- Search:
- call delete(OutputFile)
- select
- when Source = 'Amigactive' then do
- signal off error
- address command 'FlashFind 'CDName':CDTools/indices/'CDName' "'SearchStr'" NH >'OutputFile
- if RC = 5 then Matches = 0
- signal on error
- nop
- end
- when Source = 'Aminet CDs' then do
- nop
- end
- when Source = 'Aminet' then do
- nop
- end
- otherwise nop
- end
- /* Show matches or warn if none */
- /*
- if word(statef(OutFile),2) = 0 then call ReqMsg('No matches found for "'SearchStr'"')
- else address command 'Multiview' OutFile
- 'gauge id PROGR attrs' MUIA_Gauge_Current 0 MUIA_Gauge_InfoText '""'
- return
- */
- ;;;
- /* ;;; Output results */
- 'chanopen' OutputURL
- ChanID = result
- 'chanheader' ChanID '"Content-Type: text/html"'
- 'chanheader' ChanID '"Pragma: No-cache"'
- 'chandata' ChanID '"<html><head><title>Search results</title></head><body bgcolor=white>"'
- 'chandata' ChanID '"<h3 align=center>Searching for "<font color=red>'SearchStr'</font>" in 'Source'</h2>" newline'
- 'open' OutputURL
- 'chandata' ChanID '"<a href=*"file://localhost/'CDName':html/SearchCD.html*">Another search</a><p>" newline'
- 'chandata' ChanID '"<table width=*"100%*">" newline'
-
- call open(res,OutputFile,'R')
- do until eof(res)
- line = readln(res)
- if line = '' then iterate
- parse var line name 34 path
- name = strip(name,'T')
- 'chandata' ChanID '"<tr><td><a href=*"x-aweb:rexx/REXX:AAShowDir 'PathPart(path)'*">'name'</a><td>'path'" newline'
- end
- 'chandata' ChanID '"</table>" newline'
- 'chandata' ChanID '"<p><a href=*"file://localhost/'CDName':html/SearchCD.html*">Another search</a>" newline'
- 'chandata' ChanID '"</body></html>" newline'
- 'chanclose' ChanID
- call close(res)
- 'open' OutputURL
- ;;;
- /* ;;; Cleanup and exit */
- CleanUp:
- call delete(OutputFile)
- call close(res)
- exit
- ;;;
- /* ;;; Exit with a message */
- ExitMsg:
- parse arg msg
- call ShowMsg(msg)
- call CleanUp()
- return
- ;;;
- /* ;;; Error handler */
- Error:
- call ExitMsg('Error' RC 'in line' sigl)
- return
- ;;;
- /* ;;; Show a message in a requester */
- ShowMsg:
- parse arg msg
- 'request "Amigactive CD" "'msg'" "OK" nowait'
- return
- ;;;
- /* ;;; Load library */
- LoadLib:
- parse arg library
- if show('L',library) then return
- if ~exists('LIBS:'library) then address command 'copy 'CDName':System/libs/'library 'LIBS: clone quiet'
- if ~addlib(library,0,-30,0) then call ExitMsg('Failed to load' library||'0a'x||'Make sure you have run InitCD')
- return
- ;;;
-
-